<template>
    <div>
        <el-form ref="form" :model="form" label-width="100px">
            <el-form-item label="商家" >
                <el-select
                        clearable
                        v-model="form.merchantId"
                        style="max-width: 350px"
                        placeholder="请选择商家">
                    <el-option
                            v-for="item in merchantList"
                            :key="item.id"
                            :label="item.merchantName"
                            :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="供应商名称">
                <el-input v-model="form.supplierName"></el-input>
            </el-form-item>
            <el-form-item label="标签">
                <el-input v-model="form.tags"></el-input>
            </el-form-item>
            <el-form-item label="简称">
                <el-input v-model="form.shortName"></el-input>
            </el-form-item>
            <el-form-item label="联系人">
                <el-input v-model="form.contact"></el-input>
            </el-form-item>
            <el-form-item label="电话">
                <el-input v-model="form.telephone"></el-input>
            </el-form-item>
            <el-form-item label="供应商地址">
                <el-input v-model="form.address"></el-input>
            </el-form-item>
            <el-form-item prop="sort" label="排序值">
                <el-input v-model="form.sort"></el-input>
            </el-form-item>
            <el-form-item label="账期">
                <el-select v-model="form.payPeriod" placeholder="请选择">
                    <el-option
                            v-for="item in $dic.scmPayPeriod"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item prop="payDay" label="账期日">
              <el-input v-model="form.payDay" type="number" oninput="if(value.length>2)value=value.slice(0,2)" @blur="input($event)"></el-input>
            </el-form-item>
            <el-form-item label="供应商类型">
                <el-select v-model="form.supplierType" placeholder="请选择类型">
                    <el-option label="库存供应商" value="1"></el-option>
                    <el-option label="一般供应商" value="0"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item prop="status" label="是否启用">
                <el-select v-model="form.status" placeholder="请选择">
                    <el-option label="否" value="0"></el-option>
                    <el-option label="是" value="1"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="消息推送">
                <el-select v-model="form.needPush" placeholder="请选择推送状态">
                    <el-option label="否" value="0"></el-option>
                    <el-option label="是" value="1"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item prop="uid" label="通行证id">
                <el-input v-model="form.uid"></el-input>
            </el-form-item>
            <el-form-item prop="remarks" label="备注">
                <el-input v-model="form.remarks"></el-input>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
  export default {
    data() {
      return {
      }
    },
    props:{
        form:{
            type: Object,
        },
        merchantList:{
            type: Array
        }
    },
    methods: {
      onSubmit() {
        console.log('submit!');
      },
      input(e){
        let tmp = new RegExp("^[1-9][0-9]*$").test(e.target.value);
        if(!tmp){
          e.target.value = '';
        }
      }
    }
  }
</script>
